package com.mooc.meetingfilm.cinema.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.mooc.meetingfilm.cinema.controller.vo.CinemaSavedReqVO;
import com.mooc.meetingfilm.cinema.controller.vo.DescribeCinemasRespVO;
import com.mooc.meetingfilm.cinema.dao.entity.MoocCinemaT;
import com.mooc.meetingfilm.cinema.dao.mapper.MoocCinemaTMapper;
import com.mooc.meetingfilm.cinema.service.CinemaServiceAPI;
import com.mooc.meetingfilm.utils.exception.CommonServiceException;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
public class CinemaServiceImpl implements CinemaServiceAPI {

    @Resource
    private MoocCinemaTMapper cinemaTMapper;

    @Override
    public void saveCinema(CinemaSavedReqVO reqVO) throws CommonServiceException {
        MoocCinemaT cinemaT = new MoocCinemaT();
        // TODO 填写具体参数
        cinemaT.setCinemaName("");
        cinemaT.setCinemaPhone("");
        cinemaT.setBrandId(0);
        cinemaT.setAreaId(0);
        cinemaT.setHallIds("");
        cinemaT.setImgAddress("");
        cinemaT.setCinemaAddress("");
        cinemaT.setMinimumPrice(0);

        // TODO 把实体对象保存


    }

    @Override
    public IPage<DescribeCinemasRespVO> describeCinemas(int pageNow, int pageSize) throws CommonServiceException {

        // 查询实体对象，然后与表现层对象进行交互
        // TODO 提示
        Page<MoocCinemaT> page = new Page<>(pageNow, pageSize);
        IPage<MoocCinemaT> moocCinemaTIPage = cinemaTMapper.selectPage(page, null);
        moocCinemaTIPage.getRecords();

        return null;
    }
}
